<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>正泰电力服务后台</title>
<link rel="stylesheet" href="../../layui/css/layui.css" />
<!-- <script src="../../assets/areadata.js"></script> -->
<!--   <link rel="stylesheet" href="css/admin.css"/>   -->
<script src="../../statics/js/area.js"></script>
<style type="text/css">
.layui-table-cell {
	height: auto;
	line-height: 38px;
}

.layui-table-main	.layui-table-cell {
	height: 38px;
	line-height: 38px;
	padding: 0 15px;
	position: relative;
	box-sizing: border-box;
}
</style>
</head>
<body>
	<div class="container">
		<div class="content-search">
			<!-- <form class="layui-form layui-form-pane" action=""> -->
			<div class="layui-inline">
				<label class="layui-form-label">项目名称</label>
				<div class="layui-input-block">
					<input autocomplete="off" id="channelUser_id" placeholder="项目名称"
						class="layui-input" type="text" />
				</div>
			</div>
			<div class="layui-inline">
				<button class="layui-btn" data-type="reload">查询</button>
			</div>
		</div>
		<div class="tar mt10">
			<!-- <button class="layui-btn layui-btn-normal layui-btn-small add1">+添加账号</button>  -->
		</div>
		<div class="table-listm roll-x">
			<table id="msg_enter_manager" lay-filter="msg_enter_manager"></table>
		</div>
	</div>
	<div id="table-pages" style="text-align:center"></div>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script type="text/javascript" src="../../assets/data.js"></script>
	<script type="text/javascript" src="../../assets/province.js"></script>
	<script>
       function img_event(img_url){
          window.open(img_url);
       }
        var arrayObj = new Array(); ;　
    
		layui.use(['jquery', 'laydate','form','layer','laypage','table'], function(){
			var $ = layui.jquery,
			    laydate = layui.laydate,
			    layer = layui.layer,
			    table = layui.table,
			    laypage = layui.laypage;


		table.render({
			elem: '#msg_enter_manager',
			height: 'full-50',
			id:'msg_enter__table_id',
			url: '../../web/find_msg_enter',
			toolbar: '#toolbarDemo',
			page: true ,
			loading: true,
			text: {
				none: '暂无相关数据'
			},
			cellMinWidth: 80,
			cols: [
				[//{type: 'numbers', title: '序号', width: '30'},
				{field: 'id',
				 title: 'ID',
				 width:55,
				 fixed:'left', 
				 unresize: true, 
				 sort: true
				},
				{field: 'customer_type_product',title: '客户需求产品',width: 125},
				{field: 'provider_phone_number', title: '提供者手机', width: 117},
				{field: 'provider_name', title: '姓名', width:125},
				{field: 'orderNo', title: '订单号', width: 125},
				{field: 'project_name', title: '项目名称', width:125},
				{field: 'project_start_time', title: '项目启动时间', width: 153},
		        {field: 'scale', title: '项目预估规模', width:150}, 
		        {field: 'customer_type', title: '所属行业', width: 200},
		        {
		        	field: 'provid', 
		        	title: '省', 
		        	width: 100,
		        	templet:function (d) { 
		        		return provinceAndCityArray[d.provid].name
				  }
		        },
		        {
		        	field: 'cityid', 
		        	title: '市', 
		        	width: 100,
		        	templet:function (d) { 
	        			return provinceAndCityArray[d.provid].cities[d.cityid]
		        	}
		        },
		        {field: 'project_description', title: '项目详细描述', width: 200},
				{field: 'truth_type',title:'项目真实性',width:200,
				templet:function (d){
					if(d.truth_type =="0" ){
						 return "招标信息"
					}else if(d.truth_type =="1"){
						return "该项目立项信息";
					}else if(d.truth_type =="2"){
						return "甲方直接负责人联系电话";
					}else if(d.truth_type =="3"){
						return "其他证明方法";
					}
				}
				},
				{
					field: 'file_url',
					width: '150',
					title: '项目真实性内容',
					//sort: true,
					templet:function (d) { 
					     
					         if(d.truth_type =="0" || d.truth_type =="3" || d.truth_type =="1"){
					         	 if(d.file_url !=""  && d.file_url !="null" && d.file_url !="undefined"){
								 	return "<a  href="+d.file_url+" style='color:red'>点击查看</a>"
								 }else{
					         		return "无附件"
					      		}
							}else if(d.truth_type =="2"){
								return d.file_url;
							}
					    }
				},
				{
					field: 'communic', 
					title: '尽快与我取得联系', 
					width: 250,
					templet:function (d) { 
					      if(d.communic=="尽快与我取得联系"){
					      	  return "<span>√</span>"
					      }else {
					      	   return ""
					      }
					      
					 }
			    },
			    {	field: 'channel', 
					title: '我想成为（推荐）渠道商', 
					width: 250,
					templet:function (d) { 
					      if(d.channel=="我想成为（推荐）渠道商"){
					      	  return "<span>√</span>"
					      }else {
					      	   return ""
					      }
					      
					 }
			    },
				{	field: 'like_name', 
					title: '相似项目名称', 
					width: 150,
			    },
			    {	field: 'like_value', 
					title: '相似度', 
					width: 150,
			    },
				{
					field: 'createTime',
					width: '167',
					title: '创建时间',
					//sort: true
					templet:function (d) { 
					      //var newDate = new Date(d.createTime).toLocaleString();
					      return d.createTime
					 }
				},
				{
					field:'nickname',
					title:'提交用户',
					width:'150'
				},{
					field:'zf_name',
					title:'转发用户',
					width:'150'
				},
				{field: 'money', 
				title: '红包金额(元)',
				width: 100,
				templet:function (d) {
					if(d.money != "null" && d.money != "" && d.money !="undefined"){
						return "<input type='text' value="+d.money+" id='money"+d.id+"' onblur=out('"+d.id+"');>";
					}
				}
				},
				{field: 'reject_reason', 
				title: '拒绝理由',
				width: 100,
				},
				{
					width: '330',                                  
					title: '常用操作',
					fixed: 'right',
					//toolbar: "#userbar",
					templet:function (d) {
					
							//return '<button class="layui-btn layui-btn-normal layui-btn-small a1" lay-event="f_event">初审</button>'+'<button class="layui-btn layui-btn-normal layui-btn-small a1" lay-event="ff_event">复审</button>'
					      if(d.trial=='1'){ 
					          if(d.review=='1'){	 
					          		return '<button class="layui-btn layui-btn-normal layui-btn-small a1" >审核通过</button>' 
					          }
					          else if(d.review=='-1'){
					         	  return '<button class="layui-btn layui-btn-disabled" >已拒绝</button>'+
					         	 '<button class="layui-btn layui-btn-normal layui-btn-small  a1" lay-event="del" >删除</button>'
					          }
					          else{ 
					           		return '<button class="layui-btn layui-btn-normal layui-btn-disabled a1" disabled="disabled">初审通过</button>'+'<button class="layui-btn layui-btn-normal layui-btn-small a1" lay-event="reject_event">拒绝</button>'+'<button class="layui-btn layui-btn-normal layui-btn-small a1" lay-event="ff_event">复审</button>'
					          }
					      }else if(d.trial=='0'){
					          if(d.review=='-1'){
					         	 return  '<button class="layui-btn layui-btn-disabled" >已拒绝</button>'+
					         	 '<button class="layui-btn layui-btn-normal layui-btn-small  a1" lay-event="del" >删除</button>'
					          }
					          else{
					             return '<button class="layui-btn layui-btn-normal layui-btn-small a1" lay-event="f_event">初审</button>'+
					         	 '<button class="layui-btn layui-btn-normal layui-btn-small a1" lay-event="reject_event">拒绝</button>'+
					         	 '<button class="layui-btn layui-btn-normal layui-btn-small  a1"  >复审</button>'
					          }
					      }
					      
					 }
				}]
			],
			done:function(res){
			    
			},
			request: {
				pageName: 'page',
				limitName: 'size'
			},
			limit: 10,
			limits: [10, 20, 30, 40, 50]
			
			});
			
		   var active =
              {
                  reload: function () {
                      var channelUser = $('#channelUser_id').val();//获取输入框的值
                      if(channelUser ==''){
                             layer.msg("输入账户名称", {icon: 5,time:1000});return ;
                      }
                      //执行重载
                      table.reload('msg_enter__table_id',
                          {
                                where: { channelUser: channelUser}//这里传参  向后台
		                        , url: '../../web/find_msg_enter_by_name'//后台做模糊搜索接口路径
		                        , method: 'post'
                        });
                  }
              };

 			//这个是用于创建点击事件的实例
            $('.content-search  .layui-btn').on('click', function ()
            {
                var type = $(this).data('type'); ////////////////   alert(type);   alert(active[type]);  alert(active[type].call(this));
                active[type] ? active[type].call(this) : '';
            });
            
            
		/**	$(document).on("click", ".mt10 .add1", function() {
			   layer.open({
			      type:2
			      ,area:['30%', '55%']
			      ,title:"添加账户"
				  ,content: 'add_channelUser.html'
				});
				
				
			});*/


			//表格按钮监听
            table.on("tool(msg_enter_manager)", function (e) {
                  var d = e.data;  
                  var lock = false;
                  //alert(e.event);
                  if (e.event == "f_event") {
	                     id= d.id  ;
	                     layer.open({
							  content: '您确定通过 '+d.provider_name+'项目吗？'
							  ,btn: ['确定', '取消']
							  ,yes: function(index, layero){
								    	//按钮【按钮一】的回调
							            if(!lock){
							            lock=true;
							            $.ajax({
							                    type : "POST",
							                    url : '../../web/comfire_trial',
							                    //async:true,
							                    data : {
							                        id:id
							                    },
							                    dataType : "json",
							                    success : function(data) {
							                             if(data.status==false){
							                            	 layer.msg(data.msg, {icon: 5,time:1500});
													     }else{
													         layer.msg(data.msg, {icon: 1,time:1500});
													         //执行重载
										                      table.reload('msg_enter__table_id');
													     }
							                    }
							             });
							            }else{
							            	alert("请求处理中！");
							            }
							  }
							  ,btn2: function(index, layero){
							    //按钮【按钮二】的回调
							    layer.closeAll(index);
							    //return false 开启该代码可禁止点击该按钮关闭
							  }
							  ,cancel: function(){ 
							    //右上角关闭回调
							    //return false 开启该代码可禁止点击该按钮关闭
							  }
							});
                  }else if (e.event == "ff_event") {
	                     id= d.id  ;
	                     layer.open({
							  content: '您确定通过 '+d.provider_name+'项目吗？'
							  ,btn: ['确定', '取消']
							  ,yes: function(index, layero){
							            if(!lock){
							            lock=true;
								    	//按钮【按钮一】的回调
							            $.ajax({
							                    type : "POST",
							                    url : '../../web/comfire_review',
							                    //async:true,
							                    data : {
							                        id:id
							                    },
							                    dataType : "json",
							                    success : function(data) {
							                             if(data.status==false){
							                            	 layer.msg(data.msg, {icon: 5,time:1500});
													     }else{
													          if(data.msg.length>200){
													             //layer.msg(data.msg, {icon: 1,time:10000});
													             layer.close(index);
													             alert(data.msg);
													          }else{
													             layer.msg(data.msg, {icon: 1,time:2000});
													          }
													          
													         //alert(data.msg);
													         //执行重载
										                      table.reload('msg_enter__table_id');
													     }
							                    }
							             });
							             }
							  }
							  ,btn2: function(index, layero){
							    //按钮【按钮二】的回调
							    layer.closeAll(index);
							    //return false 开启该代码可禁止点击该按钮关闭
							  }
							  ,cancel: function(){ 
							    //右上角关闭回调
							    //return false 开启该代码可禁止点击该按钮关闭
							  }
							});
                  }else if (e.event == "del") {
	                     id= d.id  ;
	                     layer.open({
							  content: '您确定删除 '+d.provider_name+'项目吗？'
							  ,btn: ['确定', '取消']
							  ,yes: function(index, layero){
								    	//按钮【按钮一】的回调
							            $.ajax({
							                    type : "POST",
							                    url : '../../web/pseudo',
							                    //async:true,
							                    data : {
							                        id:id
							                    },
							                    dataType : "json",
							                    success : function(data) {
							                             if(data.status==false){
							                            	 layer.msg(data.msg, {icon: 5,time:1500});
													     }else{
													         layer.msg(data.msg, {icon: 1,time:1500});
													         //执行重载
										                      table.reload('msg_enter__table_id');
													     }
							                    }
							             });
							  }
							  ,btn2: function(index, layero){
							    //按钮【按钮二】的回调
							    layer.closeAll(index);
							    //return false 开启该代码可禁止点击该按钮关闭
							  }
							  ,cancel: function(){ 
							    //右上角关闭回调
							    //return false 开启该代码可禁止点击该按钮关闭
							  }
							});
                  }
                  else{
                      id= d.id  ;
                      //alert(id);
                      layer.open({
					      type:2
					      ,area:['50%', '60%']
					      ,title:"不通过理由"
						  ,content: 'reject_page.html?id='+id
					 });
                  }
              
            });			
			
		});
function out(id){
         var money = $("#money"+id+"").val();
	
			
			layer.open({
							  content: '您确定修改红包金额吗？'
							  ,btn: ['确定', '取消']
							  ,yes: function(index, layero){
								    	//按钮【按钮一】的回调
							            $.ajax({
							                    type : "POST",
							                    url : '../../web/msgUpdate',
							                    //async:true,
							                    data : {
							                        id:id,
							                        money:money
							                    },
							                    dataType : "json",
							                    success : function(data) {
							                           layer.msg(data.msg, {icon: 1,time:1500});
							                    }
							             });
							  }
							  ,btn2: function(index, layero){
							    //按钮【按钮二】的回调
							    layer.closeAll(index);
							    //return false 开启该代码可禁止点击该按钮关闭
							  }
							  ,cancel: function(){ 
							    //右上角关闭回调
							    //return false 开启该代码可禁止点击该按钮关闭
							  }
							});
							
							
};

	</script>
    <script type="text/html" id="toolbarDemo">
 		
	</script>

</body>

</html>
















